# coding = utf-8
# 这是一个MintRss的采集规则文件
# 热血小说网 http://www.rexue.org/
# 最后更新 2020.12.08 v1.0
# rule vars
charset = "utf-8"  # e.g.: utf-8, gbk etc.
name = "热血小说网"
url = "https://www.rexue.org/"  # index url
search = {
    "url": "https://www.rexue.org/search.php",
    "method": "get",
    "input": "key",
    "data": {},
    "headers":{}
}  # search page
searchPattern = {
    "bookLists":"bs:(class_='result')[0]('li') if '搜索' in i.title.text else i('html')",    # booklists result must be list
    "bookName":"bs:.h3.a['title'] if i.title is None else i.h1.em.text",
    "bookAuthor":"bs:.span.a.text if i.title is None else i(class_='cf')[0].h1.a.text",
    "bookUrl":"bs:(class_='read_btn')[0]['href'] if i.title is None else i(class_='cf')[0].a['href']",
    "lastChapter":"bs:('p')[1].a.text if i.title is None else i(class_='cf')[0](class_='intro')[1].a.text",
    "bookCover":"bs:.img['src']",
    "whichBook":"books[0]"
}
bookPattern={
    "tocUrl":"book[2]",  # if same as the bookUrl , use book[2]
    "bookIntro":"bs: and re.sub('阅读.+?小说.+$','',i(class_='intro')[0].text)"   # book introduction text
}
tocPattern={
    # "chapterList":"",
    # for decreasing the search scope of chapter
    "chapterUrl":"bs: and [x.a['href'] for x in i(id='chapter')]",
    "chapterName":"bs: and [x.text for x in i(id='chapter')]"
}
chapterPattern={
    "name": "bs:.h2.text",
    "content":"bs: and  '<br>'.join([x.text for x in i(id='txt')[0].find_all('p')[:-1]])",
    "filter":"content",
}